<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition template="/templates/user_template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core">

	<ui:define name="title">
        Chocolor:My drafts
    </ui:define>

	<ui:define name="content">
		<c:if test="#{securityBean.isAuthenticated()}">
			<h:form>
				<p:dataTable id="table" var="orderDraft"
					value="#{orderDraftList.orderDrafts}" paginator="true" rows="10"
					widgetVar="orderDraftsTable">
					<f:facet name="header">
						<div style="text-align: right">
							<p:outputPanel>
								<h:outputText value="Search all fields:" />
								<p:inputText id="globalFilter"
									onkeyup="orderDraftsTable.filter()" style="width:150px" />
							</p:outputPanel>
						</div>
					</f:facet>

					<p:column sortBy="#{orderDraft.orderDraftId}"
						filterBy="#{orderDraft.orderDraftId}" style="width:10%">
						<f:facet name="header">
							<h:outputText value="Order Id:" />
						</f:facet>
						<h:outputText value="#{orderDraft.orderDraftId}" />
					</p:column>

					<p:column sortBy="#{orderDraft.orderName}"
						filterBy="#{orderDraft.orderName}" style="width:30%">
						<f:facet name="header">
							<h:outputText value="Order Name" />
						</f:facet>
						<h:outputText value="#{orderDraft.orderName}" />
					</p:column>

					<p:column sortBy="#{orderDraft.articleId}"
						filterBy="#{orderDraft.articleId}" style="width:20%">
						<f:facet name="header">
							<h:outputText value="Article" />
						</f:facet>
						<h:outputText value="#{orderDraft.articleId}" />
					</p:column>

					<p:column sortBy="#{orderDraft.orderDraftDate}"
						filterBy="#{orderDraft.orderDraftDate}" style="width:20%">
						<f:facet name="header">
							<h:outputText value="Draft date" />
						</f:facet>
						<h:outputText value="#{orderDraft.orderDraftDate}" />
					</p:column>

					<p:column>
						<p:commandButton value="Make order"
							action="#{orderDraftList.editOrder(orderDraft.orderDraftId)}"
							icon="ui-icon-pencil" ajax="false" />
						<p:commandButton
							action="#{orderDraftList.removeDraft(orderDraft.orderDraftId)}"
							icon="ui-icon-trash" ajax="false" />
					</p:column>
				</p:dataTable>
			</h:form>
		</c:if>
	</ui:define>
</ui:composition>
